using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace ASP_TF2LogParser.UserControls
{
    public partial class PlayerTop5Killers : System.Web.UI.UserControl
    {
        protected void Page_Load( object sender, EventArgs e )
        {

        }

        public void GeneratePlayerKillersTable( string victimPlayerId )
        {
            LogParser.DA.DataObjects.PlayerStatsDS.PlayersSelectPlayerKillersTop5ByVictimPlayerIdDataTable dt = LogParser.DA.PlayerModel.GetTop5PlayerKillers( victimPlayerId );
            
            System.Collections.Generic.List<string> playerIds = new System.Collections.Generic.List<string>();

            foreach ( LogParser.DA.DataObjects.PlayerStatsDS.PlayersSelectPlayerKillersTop5ByVictimPlayerIdRow dr in dt.Rows )
                playerIds.Add( dr.PlayerId );

            dt.Columns.Remove( "PlayerId" );

            PlayerTop5KillersGridView.DataSource = dt;
            PlayerTop5KillersGridView.DataBind();

            int counter = 0;


            foreach ( GridViewRow row in PlayerTop5KillersGridView.Rows )
            {
                string playerId = playerIds[ counter ].ToString();

                Label tempLabel = new Label();
                tempLabel.Text = "<a href=\"Player.aspx?playerId=" + playerId + "\">" + row.Cells[ 0 ].Text + "</a>";
                row.Cells[ 0 ].Controls.Add( tempLabel );

                counter++;
            }


        }
    }
}